import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_circles, make_blobs
X1,y1 = make_circles(n_samples=5000, factor=0.6, noise=0.05)
X2,y2 = make_blobs(n_samples=1000,n_features=2, centers=[[1.2, 1.2]],
cluster_std=[[.1]], random_state=9)
X= np.r_[X1,X2]
plt.scatter(X[:, 0], X[:, 1], marker='o')
# plt.show()
from sklearn.cluster import KMeans
y_pred =KMeans(n_clusters=3, random_state=9).fit_predict(X)
plt.scatter(X[:, 0], X[:, 1], c=y_pred)
plt.show()
from sklearn.cluster import DBSCAN
y_pred = DBSCAN(eps=0.1,min_samples=10).fit_predict(X)
plt.scatter(X[:, 0],X[:, 1],c=y_pred)
plt.show()